package ihm.overlays;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

import ihm.main.Window;
import ihm.widgets.Album;

public class AlbumsOverlay extends Composite
{

	public AlbumsOverlay( Composite father )
	{
		super( father, SWT.NONE );
		setLayout( new GridLayout( 4, true ) );
	}
	
	public void addAlbum( String albumName, Image picture, String aID ) {
		new Album( this, albumName, picture, aID );
	}

	public void update() {
		clearLayout();
		for( int i = 0; i < 9; i++ )
		{
			addAlbum( "album " + i, new Image( Window.getInstance().getDisplay(), "C:/Users/Clem/Documents/UTC/LO23/tux-gendarme-mobile.png"  ), "alb" + i );
		}
		layout();
	}

	private void clearLayout() {
		Control[] composites = getChildren();
		for( int i = 0; i < composites.length; i++ ) {
			composites[i].dispose();
		}
	}

}
